package com.projet.whattowatch.adapter;

import java.util.ArrayList;

import com.projet.whattowatch.R;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
 
public class CommentAdapter extends ArrayAdapter<String>
{
	private final Activity context;
	private final ArrayList<String> name;
	private final ArrayList<String> rating;
	private final ArrayList<String> comment;
	
	public CommentAdapter(Activity context, ArrayList<String> name, ArrayList<String> rating, ArrayList<String> comment)
	{
		super(context, R.layout.custom_linear_comment, name);
		this.context = context;
		this.name = name;
		this.comment = comment;
		this.rating = rating;
	}
	
	@Override
	public int getCount()
	{
        return name.size();
    }
	
	@Override
	public View getView(final int position, View convertView, ViewGroup parent)
	{
		LayoutInflater inflater = context.getLayoutInflater();
		View rootView = inflater.inflate(R.layout.custom_linear_comment, null);
		
		TextView nameUser = (TextView) rootView.findViewById(R.id.nameTextView);
		TextView commentText = (TextView) rootView.findViewById(R.id.commentTextView);
		nameUser.setText(name.get(position) + " a donné " + rating.get(position) + " étoiles !");
		commentText.setText(comment.get(position));
		
		return rootView;
	}
}